
;((doc,storage,location) => {
  const username = doc.querySelector('#username')
  const enter = doc.querySelector('#enter')

  const init = () => {
    bindEvents()
  }

  function bindEvents() {
    enter.addEventListener('click', handleEnterClick, false)
  }

  function handleEnterClick() {
    const uname = username.value.trim()

    if (uname.length <= 6) {
      alert('用户名必须大于6位')
      return
    }

    storage.setItem('uname', uname)
    location.href = 'index.html'
  }

  init()

})(document,localStorage,location)
